import { _decorator, Component, find, instantiate, Node, Prefab } from 'cc';
import { MainLlogic } from '../scripts/MainLlogic';
const { ccclass, property } = _decorator;

@ccclass('Resrt')
export class Resrt extends Component {
    private mainLogic:Node = null
    /**
     * 粒子特效
     */
    @property({type:Prefab})
    private pre:Prefab = null
    start() {
        this.mainLogic = find('Canvas/MainLogic')
        this.node.on(Node.EventType.TOUCH_START,this.touchStart,this)
    }

    touchStart(){
        let n = instantiate(this.pre)
        this.node.getParent().addChild(n)
        n.position = this.node.position
        this.mainLogic.getComponent(MainLlogic).revive()
        find('Canvas/re').destroy()
        this.node.destroy()
    }

    update(deltaTime: number) {
        
    }
}


